
package  main

import (
	"crypto/md5"
	"encoding/hex"
	"fmt"
	"io"
	"strconv"
	"strings"
	"time"
)

//生成随机字符串//
func CreateRandomStr(seedStr string) string {
	h := md5.New()
	seedStr = seedStr + strconv.FormatInt(time.Now().UnixNano(), 10)
	_, _ = io.WriteString(h, seedStr)
	cipherStr := h.Sum(nil)
	payNum := hex.EncodeToString(cipherStr)
	return payNum
}



func test1() {
	//1
	list := make([]int, 0)
	list = append(list, 1)
	fmt.Println(list)
	//2
	s1 := []int{1,2,3}
	s2 := []int{4,5,6}
	s := append(s1, s2...)
	fmt.Println(s)
	//3
	var (
		size = 1024
		maxSize = size *2
	)
	fmt.Println(size, maxSize)
}

//结构体比较
func test2(){
	sn1 := struct {
		name string
		age int
	}{"sn", 10}
	sn2 := struct {
		name string
		age int
	}{"sn", 10}
	if sn1 == sn2 {
		fmt.Println("sn1 == sn2")
	}
	//那什么是可比较的呢，常见的有 bool、数值型、字符、指针、数组等，像切片、map、函数等是不能比较的
	//sp1 := struct {
	//	name string
	//	h map[string]string
	//}{"sp", map[string]string{"sex":"ma"}}
	//sp2 := struct {
	//	name string
	//	h map[string]string
	//}{"sp", map[string]string{"sex":"ma"}}
	//if sp1 == sp2 {
	//	fmt.Println("sp1 == sp2")
	//}

}

//字符串
func test3()  {
	str := `11` + "22"
	s := []string{"foo", "bar", "baz"}
	fmt.Println(strings.Join(s, "222 "))
	fmt.Println(str)

	//const
	const (
		x = iota
		_
		y
		z = "z"
		k
		p = iota
	)
	fmt.Println(x,y,z,k, p)

	//nil 值。nil 只能赋值给指针、chan、func、interface、map 或 slice 类型的变量
	var e error = nil

	fmt.Println(e)

}

func main() {
	str := CreateRandomStr("test")
	fmt.Println(str)

	test1()
	test2()
	test3()

	fmt.Printf("____%v  444\n", "222")
	fmt.Printf("____%+v  444 \n", "222")
	var a []byte
	s := string(a)
	fmt.Println(s,33)
}
